<%--
  Created by IntelliJ IDEA.
  User: 88403
  Date: 2021/6/16
  Time: 21:55
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>留言管理</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        function deleteLeave(lid){
            var res = confirm("是否删除");
            if(res==true){
                location.href="${pageContext.request.contextPath}/leave/deleteLeave?lid="+lid;
            }
        }
    </script>
</head>
<body>
<%@include file="header.jsp"%>
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="index.jsp">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">留言管理</span></div>
        </div>
        <div class="result-wrap">
                <div class="result-title">
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th>序号</th>
                            <th>姓名</th>
                            <th>电话</th>
                            <th>电子邮件</th>
                            <th>回复状态</th>
                            <th>操作</th>
                        </tr>
                        <c:forEach items="${pi.list}" var="l" varStatus="i">
                            <tr>
                                <td>${i.count}</td>
                                <td>${l.lname}</td>
                                <td>${l.lphone}</td>
                                <td>${l.lmail}</td>
                                <c:if test="${l.lback==null}">
                                    <td>未回复</td>
                                </c:if>
                                <c:if test="${l.lback!=null}">
                                    <td>已回复</td>
                                </c:if>
                                <td>
                                    <button onclick="deleteLeave(${l.lid})" class="btn btn-danger btn-sm">删除</button>&nbsp;&nbsp;
                                    <c:if test="${l.lback==null}">
                                        <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal${l.lid}" >回复</button>&nbsp;&nbsp;
                                     </c:if>
                                     <c:if test="${l.lback!=null}">

                                      </c:if>

                                    <!-- 弹出模态框 -->

                                    <div class="modal fade"  tabindex="-1" role="dialog" id="myModal${l.lid}">
                                        <div class="modal-dialog" role="document" >
                                            <div class="modal-content" style="height: 400px;width:600px" >
                                                <div class="modal-header" >
                                                    <button type="button" class="close" data-dismiss="modal">
                                                        <span>&times;</span>
                                                    </button>
                                                    <h4 class="modal-title">回复评论</h4>
                                                </div>
                                                <form action="${pageContext.request.contextPath}/leave/update?lid=${l.lid}" method="post" class="form-horizontal">
                                                    <div class="motal-body" align="center">
                                                        <table>
                                                            <tr>
                                                                <td><label>问题：</label></td>
                                                                <td>
                                                                    <textarea  style="height: 50px;width: 500px">${l.lcontent}</textarea>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td><label>回复：</label></td>
                                                                <td>
                                                                    <textarea  style="height: 150px;width: 500px" name="lback"  value="${l.lback}"></textarea>
                                                                </td>
                                                            </tr>

                                                        </table>

                                                        <button type="submit" class="btn btn-primary">回复</button>

                                                    </div>

                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </td>


                            </tr>
                        </c:forEach>
                    </table>
                    <div class="Pages" align="center">
                        <span >目前在第<b>${pi.pageNum}</b>页,</span>
                        <span class="p_count">共有<b>${pi.pages}</b>页,</span>
                        <span class="p_total">本页共有<b>${pi.size}</b>条记录</span>
                        <span class="p_page">
                              <a href="${pageContext.request.contextPath}/leave/showlist?pageNum=1" class="a_first">首页</a>
                           <c:if test="${pi.hasPreviousPage}">
                               <a href="${pageContext.request.contextPath}/leave/showlist?pageNum=${pi.pageNum-1}" class="a_prev">上一页</a>
                           </c:if>
                            <c:forEach begin="1" end="${pi.pages}" var="index">
                                <c:if test="${pi.pageNum==index}">
                                    <li class="active" style="display: inline;">
                                        <a href="${pageContext.request.contextPath}/leave/showlist?pageNum=${index}" style=" line-height: 20px;color: black; text-decoration: none;padding: 10px 10px;">${index}</a>
                                    </li>
                                </c:if>
                                <c:if test="${pi.pageNum!=index}">
                                    <li class="" style="display: inline;">
                                        <a href="${pageContext.request.contextPath}/leave/showlist?pageNum=${index}" style=" line-height: 20px;color: black; text-decoration: none;padding: 10px 10px;">${index}</a>
                                    </li>
                                </c:if>
                            </c:forEach>

                            <c:if test="${pi.hasNextPage}">
                                <a href="${pageContext.request.contextPath}/leave/showlist?pageNum=${pi.pageNum+1}" class="a_next">下一页</a>
                            </c:if>
                             <a href="${pageContext.request.contextPath}/leave/showlist?pageNum=${pi.pages}" class="a_end">末页</a>
                          </span>
                    </div>
                </div>
        </div>
    </div>
    </div>
</div>
</body>
</html>
